<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue-绑定</title>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <style>
        .base {
            width: 100px;
            height: 100px;
        }

        .active {
            background: red;
        }

        .text-danger {
            background: green;
        }
    </style>
</head>
<body>
<div id="app">
    <!--
        <div class="static" v-bind:class="{'active':isActive,'text-danger': hasError}"></div>
    -->
    <div v-bind:class="classObject"></div>
</div>
</body>

<script>
    new Vue({
        el: '#app',
        data: {
            isActive: true,
            error: {
                value: true,
                type: 'fatal'
            }
        },
        computed:{
            classObject: function () {
                return{
                    base:true,
                    active: this.isActive && !this.error.value,
                    'text-danger':this.error.value&&this.error.type==='fatal'
                }

            }
        }
    })
</script>
</html>